<!--
 * @Author: wjk
 * @Date: 2019-12-31 15:40:51
 * @LastEditors: wjk
 * @LastEditTime: 2019-12-31 15:51:20
 * @description: file content
 -->
<template>
  <base-page-view class-name="film-container">
    <view v-if="dialogShow" class="dialog">
      <b-image src="/static/images/films/dialog.png" mode="widthFix" :is-asset="true" />
      <b-image class="btn" src="/static/images/films/btn.png" mode="widthFix" :is-asset="true" @click="toActivity" />
    </view>
  </base-page-view>
</template>

<script>
import { mapState } from 'vuex'
import './index.scss'
export default {
  components: {
  },
  data() {
    return {
      dialogShow: false
    }
  },
  computed: {
    ...mapState([
      'token'
    ])
  },
  onLoad() {
    this.$setNavTitle('全网影视')
  },
  onShow() {
    if (this.token) {
      this.fetchData()
    } else {
      this.$navigateTo('/pages/login/index')
    }
  },
  methods: {
    async fetchData() {
      const res = await this.$api.earnApi.getEarningV2New({ memberType: 3 })
      if (res.success && res.data && res.data.is_buy) {
        this.dialogShow = false
        this.fetchActivityData()
      } else {
        this.dialogShow = true
      }
    },
    async fetchActivityData() {
      const res = await this.$api.excellentApi.getActivity({
        page_no: 1,
        page_size: 10,
        activity_id: 'dfd352be-3265-4dcf-9473-22c32aea8d6c'
      })
      if (res.success && res.data && res.data.activity) {
        this.filmUrl = JSON.parse(res.data.activity.comment).share_title

        // #ifdef H5
        location.href = this.filmUrl || 'http://vip.lvylv.cn'
        // #endif
      }
    },
    toActivity() {
      this.$navigateTo('/pagesDetail/template/index?id=a6a84a2a-5306-46f9-a597-1ccd48036da8')
    }
  }
}
</script>
